package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.OaAccountsReceivableSummary;
import com.ruoyi.system.service.IOaAccountsReceivableSummaryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * OA系统应收账款汇总Controller
 *
 * @author ruoyi
 * @date 2025-03-14
 */
@RestController
@RequestMapping("/system/summarys")
@Transactional
public class OaAccountsReceivableSummaryController extends BaseController
{
    @Autowired
    private IOaAccountsReceivableSummaryService oaAccountsReceivableSummaryService;

    /**
     * 查询OA系统应收账款汇总列表
     */
    @PreAuthorize("@ss.hasPermi('system:summarys:list')")
    @GetMapping("/list")
    public TableDataInfo list(OaAccountsReceivableSummary oaAccountsReceivableSummary)
    {
        startPage();
        List<OaAccountsReceivableSummary> list = oaAccountsReceivableSummaryService.selectOaAccountsReceivableSummaryList(oaAccountsReceivableSummary);
        return getDataTable(list);
    }

    /**
     * 导出OA系统应收账款汇总列表
     */
    @PreAuthorize("@ss.hasPermi('system:summarys:export')")
    @Log(title = "OA系统应收账款汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OaAccountsReceivableSummary oaAccountsReceivableSummary)
    {
        List<OaAccountsReceivableSummary> list = oaAccountsReceivableSummaryService.selectOaAccountsReceivableSummaryList(oaAccountsReceivableSummary);
        ExcelUtil<OaAccountsReceivableSummary> util = new ExcelUtil<OaAccountsReceivableSummary>(OaAccountsReceivableSummary.class);
        util.exportExcel(response, list, "OA系统应收账款汇总数据");
    }

    /**
     * 获取OA系统应收账款汇总详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:summarys:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(oaAccountsReceivableSummaryService.selectOaAccountsReceivableSummaryById(id));
    }

    /**
     * 新增OA系统应收账款汇总
     */
    @PreAuthorize("@ss.hasPermi('system:summarys:add')")
    @Log(title = "OA系统应收账款汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OaAccountsReceivableSummary oaAccountsReceivableSummary)
    {
        return toAjax(oaAccountsReceivableSummaryService.insertOaAccountsReceivableSummary(oaAccountsReceivableSummary));
    }

    /**
     * 修改OA系统应收账款汇总
     */
    @PreAuthorize("@ss.hasPermi('system:summarys:edit')")
    @Log(title = "OA系统应收账款汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OaAccountsReceivableSummary oaAccountsReceivableSummary)
    {
        return toAjax(oaAccountsReceivableSummaryService.updateOaAccountsReceivableSummary(oaAccountsReceivableSummary));
    }

    /**
     * 删除OA系统应收账款汇总
     */
    @PreAuthorize("@ss.hasPermi('system:summarys:remove')")
    @Log(title = "OA系统应收账款汇总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(oaAccountsReceivableSummaryService.deleteOaAccountsReceivableSummaryByIds(ids));
    }
    @GetMapping("/list1")
    public TableDataInfo list1(Long id)
    {
        OaAccountsReceivableSummary oaAccountsReceivableSummary = new OaAccountsReceivableSummary();
        oaAccountsReceivableSummary.setProjectId(id);
        List<OaAccountsReceivableSummary> list = oaAccountsReceivableSummaryService.selectOaAccountsReceivableSummaryList(oaAccountsReceivableSummary);
        return getDataTable(list);
    }

}
